package com.mine.redis.util.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author weixiao
 * @date 2024/8/16 13:51
 */
@Mapper
public interface OrderMapper {

    @Select("select count(*) from t_order where user_id = #{userId} and coupon_id = #{couponId}")
    Integer countOrder(@Param("userId") Integer userId, @Param("couponId") Integer couponId);

    @Insert("insert into t_order(id, user_id, coupon_id, create_time) values (#{id}, #{userId}, #{couponId}, now())")
    void buyCoupon(@Param("id") Long id, @Param("userId") Integer userId, @Param("couponId") Integer couponId);
}
